package liveclient

import (
	"context"
	"github.com/zeromicro/go-zero/zrpc"
	"google.golang.org/grpc"
	"grpc-common/live/types/live"
)

type (
	GetAllTagReq       = live.GetAllTagReq
	GetAllTagResp      = live.GetAllTagResp
	GetCurrentLiveReq  = live.GetCurrentLiveReq
	GetCurrentLiveResp = live.GetCurrentLiveResp
	Live               interface {
		GetAllTag(ctx context.Context, in *GetAllTagReq, opts ...grpc.CallOption) (*GetAllTagResp, error)
		GetCurrentLive(ctx context.Context, in *GetCurrentLiveReq, opts ...grpc.CallOption) (*GetCurrentLiveResp, error)
	}

	defaultLive struct {
		cli zrpc.Client
	}
)

func (m *defaultLive) GetCurrentLive(ctx context.Context, in *GetCurrentLiveReq, opts ...grpc.CallOption) (*GetCurrentLiveResp, error) {
	client := live.NewLiveClient(m.cli.Conn())
	return client.GetCurrentLive(ctx, in, opts...)
}

func NewLive(cli zrpc.Client) Live {
	return &defaultLive{
		cli: cli,
	}
}

func (m *defaultLive) GetAllTag(ctx context.Context, in *GetAllTagReq, opts ...grpc.CallOption) (*GetAllTagResp, error) {
	client := live.NewLiveClient(m.cli.Conn())
	return client.GetAllTag(ctx, in, opts...)
}
